#@layoutT('')
#define main()
<div class="container-wrap">
    <table id="maingrid" lay-filter="maingrid"></table>
</div>
#end

#define js()
<script type="text/html" id="bar_maingrid">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
</script>

<script>
    gridArgs.title = '';
    gridArgs.dataId = 'id';
    gridArgs.deleteUrl = '#(path)/user/upload/file/delete';
    gridArgs.updateUrl = '#(path)/user/upload/file/edit/';
    gridArgs.addUrl = '#(path)/user/upload/file/add';
    gridArgs.gridDivId = 'maingrid';
    initGrid({
        id: 'maingrid'
        , elem: '#maingrid'
        , cellMinWidth: 100
        , cols: [[
            {title: '主键', field: 'id', width: 35, checkbox: true},
            {title: '序号', type: 'numbers', width: 35},
            {title: '用户名', field: 'user_code'},
            {title: '文件名称', field: 'name'},
            {title: '激活码', field: 'active_code'},
            {title: '唯一标识', field: 'identifier'},
            {title: '应用名称', field: 'app_name'},
            {title: '应用版本', field: 'app_version'},
            {title: '文件类型', field: 'type', templet: '#numToFileType'},
            {title: '运行时间', field: 'run_time', edit: 'text'},
            {title: '创建时间', field: 'create_time'},
            {title: '操作',fixed:'right',width : 180,align : 'left',toolbar : '#bar_maingrid'} // 这里的toolbar值是模板元素的选择器
        ]]
        , url: "#(path)/user/upload/file/list"
        , searchForm: 'searchForm'
    });

</script>


<script type="text/html" id="numToFileType">
    #[[
    {{# if(d.type==1){ }}
    普通场景
    {{# } }}

    {{# if(d.type==2){ }}
    昙花场景
    {{# } }}
    ]]#
</script>

#end


#define layuiFunc()
    //监听单元格编辑
    table.on('edit(maingrid)', function(obj){
        var value = obj.value //得到修改后的值
        ,data = obj.data //得到所在行所有键值
        ,field = obj.field; //得到字段
        var params="userUploadFile."+field+"="+value;

        $.post("#(path)/user/upload/file/updateFieldValue?"+params
            ,param({
            'userUploadFile.id' : data.id
        })
        ,function(feedback){
            $(".layui-laypage-btn").click();
            layer.msg(feedback.msg);
        });
    });
#end







